<?php
define( 'ROOT', dirname ( dirname ( __FILE__ ) ) );
include_once( ROOT.'/../cola/core/colaapp.php' );
include_once(ROOT.'/app/config/config.php' );
include_once(SDK."taobao/TopSdk.php");
include_once(SDK."taobao/top/TopClient.php");
include_once(SDK."taobao/top/request/TbkItemsGetRequest.php");
include_once(SDK."taobao/top/request/TmallItemsDiscountSearchRequest.php");
include_once(SDK."taobao/top/RequestCheckUtil.php");
include_once(SDK."taobao/lotusphp_runtime/Logger/Logger.php");

ini_set("memory_limit", "1024M");
class Pull_spreed_goods
{
	function get_by_keyword()
	{
// 		$c = new TopClient;
// 		$c->appkey = TAOBAO_APP_KEY;
// 		$c->secretKey = TAOBAO_APP_SECRET;
// 		$c->format = 'json';
// 		$req = new TbkItemsGetRequest;
// 		$req->setFields("num_iid");
// 		$req->setKeyword("夏季短裙");
// 		$req->setCid(123);
// 		$req->setStartPrice("1");
// 		$req->setEndPrice("999");
// 		$req->setAutoSend("true");
// 		$req->setArea("杭州");
// 		$req->setStartCredit("1heart");
// 		$req->setEndCredit("1heart");
// 		$req->setSort("price_desc");
// 		$req->setGuarantee("true");
// 		$req->setStartCommissionRate("1234");
// 		$req->setEndCommissionRate("2345");
// 		$req->setStartCommissionNum("1000");
// 		$req->setEndCommissionNum("10000");
// 		$req->setStartTotalnum("1");
// 		$req->setEndTotalnum("10");
// 		$req->setCashCoupon("true");
// 		$req->setVipCard("true");
// 		$req->setOverseasItem("true");
// 		$req->setSevendaysReturn("true");
// 		$req->setRealDescribe("true");
// 		$req->setOnemonthRepair("true");
// 		$req->setCashOndelivery("true");
// 		$req->setMallItem("true");
// 		$req->setPageNo(1);
// 		$req->setPageSize(40);
// 		$req->setIsMobile("true");
// 		$resp = $c->execute($req);
// 		var_dump($resp);
		
		
		$key_word = '短裙';
		$c = new TopClient;
		$c->appkey = TAOBAO_APP_KEY;
		$c->secretKey = TAOBAO_APP_SECRET;
		$c->format = 'json';
		$req = new TmallItemsDiscountSearchRequest;
		$req->setQ(urlencode( $key_word ) );
		//$req->setCat("2");
		$req->setStart(0);
		$req->setSort("sort=s");
		//$req->setBrand(20531);
		//$req->setPostFee(-1);
		$req->setStartPrice("100");
		$req->setEndPrice("500");
		//$req->setAuctionTag(3458);
		$resp = $c->execute($req);
		var_dump($resp);
	}
	function run()
	{
		$this->get_by_keyword();
	}
}
$test = new Pull_spreed_goods();
$test->run();
